<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Agregar.aspx.cs" Inherits="loggedin_Agregar" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link rel="stylesheet" href="../css/wide.css" type="text/css" media="screen, projection" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="NavigationContent" Runat="Server">
<ul id="main-nav" class="clearfix">
                    <li><a href="../Default.aspx">Inicio</a></li>
                    <li>Agregar</li>
                    <li><a href="Listar.aspx">Listar</a></li>
                    <li id="right-tab"><a href="#">Contacto</a></li>
                </ul>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" Runat="Server">
    <span style="color: #ffffff">Agrega los libros que quieras prestar:</span>
    <br />
    <div style="margin-left:auto;margin-right:auto; text-align: left;">
    <table cellpadding="4px" cellspacing="2px" style="width:100%;border-top: navy 2px solid; margin-top: 15px; border-left-width: thin; border-left-color: silver; border-bottom-width: thin; margin-bottom: 2px; border-bottom-color: silver; background-color: lightsteelblue; text-align: center; border-right-width: thin; border-right-color: silver">
        <tr>
            <td style="width: 89px" align="left">
                <asp:Label ID="Label4" runat="server" Text="Titulo:" Font-Bold="True" ForeColor="White"></asp:Label></td>
            <td align="left">
                <asp:TextBox ID="txtTitulo" runat="server" Width="80%"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 89px" align="left">
                <asp:Label ID="Label2" runat="server" Text="Autor:" Font-Bold="True" ForeColor="White"></asp:Label></td>
            <td align="left">
                <asp:TextBox ID="txtAutor" runat="server" Width="80%"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 89px" align="left">
                <asp:Label ID="Label3" runat="server" Text="Editorial:" Font-Bold="True" ForeColor="White"></asp:Label></td>
            <td align="left">
                <asp:TextBox ID="txtEditorial" runat="server" Width="80%"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 89px; height: 20px;" align="left">
                &nbsp;<asp:Label ID="Label1" runat="server" Text="URL Foto:" Font-Bold="True" ForeColor="White" Width="74px"></asp:Label></td>
            <td style="height: 20px" align="left">
                <asp:TextBox ID="txtUrlFoto" runat="server" Width="80%"></asp:TextBox></td>
        </tr>
        <tr>
            <td align="left" style="width: 89px; height: 33px">
            </td>
            <td align="left" style="height: 33px">
                </td>
        </tr>
        <tr>
            <td align="left" style="width: 89px">
            </td>
            <td align="right">
                <asp:Button ID="btnAgregar" runat="server" OnClick="btnAgregar_Click" Text="Agregar" /></td>
        </tr>
    </table>
        <br />
        <br />
        <asp:Label ID="Label5" runat="server" ForeColor="White" Text="Estos son tus libros hasta el momento:"></asp:Label></div>    
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="90%" DataKeyNames="id">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                SortExpression="id" />
            <asp:BoundField DataField="Titulo" HeaderText="Titulo" SortExpression="Titulo" />
            <asp:BoundField DataField="Autor" HeaderText="Autor" SortExpression="Autor" />
            <asp:BoundField DataField="Editorial" HeaderText="Editorial" SortExpression="Editorial" />
            <asp:BoundField DataField="Prestado_a" HeaderText="Prestado_a" SortExpression="Prestado_a" />
            <asp:ImageField DataImageUrlField="Imagen">
                <ControlStyle Height="110px" Width="80px" />
            </asp:ImageField>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        </Columns>
        <RowStyle BackColor="White" />
        <HeaderStyle BackColor="#E0E0E0" ForeColor="Black" />
        <AlternatingRowStyle BackColor="WhiteSmoke" />
    </asp:GridView>
    &nbsp;
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:autoGeneratedConnection %>"
        SelectCommand="SELECT [Titulo], [Autor], [Editorial], [Prestado_a], [Imagen], [id] FROM [TodoJunto]" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [TodoJunto] WHERE [id] = @original_id AND (([Titulo] = @original_Titulo) OR ([Titulo] IS NULL AND @original_Titulo IS NULL)) AND (([Autor] = @original_Autor) OR ([Autor] IS NULL AND @original_Autor IS NULL)) AND (([Editorial] = @original_Editorial) OR ([Editorial] IS NULL AND @original_Editorial IS NULL)) AND (([Prestado_a] = @original_Prestado_a) OR ([Prestado_a] IS NULL AND @original_Prestado_a IS NULL)) AND (([Imagen] = @original_Imagen) OR ([Imagen] IS NULL AND @original_Imagen IS NULL))" InsertCommand="INSERT INTO [TodoJunto] ([Titulo], [Autor], [Editorial], [Prestado_a], [Imagen]) VALUES (@Titulo, @Autor, @Editorial, @Prestado_a, @Imagen)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [TodoJunto] SET [Titulo] = @Titulo, [Autor] = @Autor, [Editorial] = @Editorial, [Prestado_a] = @Prestado_a, [Imagen] = @Imagen WHERE [id] = @original_id">
        <DeleteParameters>
            <asp:Parameter Name="original_id" Type="Int32" />
            <asp:Parameter Name="original_Titulo" Type="String" />
            <asp:Parameter Name="original_Autor" Type="String" />
            <asp:Parameter Name="original_Editorial" Type="String" />
            <asp:Parameter Name="original_Prestado_a" Type="String" />
            <asp:Parameter Name="original_Imagen" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Titulo" Type="String" />
            <asp:Parameter Name="Autor" Type="String" />
            <asp:Parameter Name="Editorial" Type="String" />
            <asp:Parameter Name="Prestado_a" Type="String" />
            <asp:Parameter Name="Imagen" Type="String" />
            <asp:Parameter Name="original_id" Type="Int32" />
            <asp:Parameter Name="original_Titulo" Type="String" />
            <asp:Parameter Name="original_Autor" Type="String" />
            <asp:Parameter Name="original_Editorial" Type="String" />
            <asp:Parameter Name="original_Prestado_a" Type="String" />
            <asp:Parameter Name="original_Imagen" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Titulo" Type="String" />
            <asp:Parameter Name="Autor" Type="String" />
            <asp:Parameter Name="Editorial" Type="String" />
            <asp:Parameter Name="Prestado_a" Type="String" />
            <asp:Parameter Name="Imagen" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    <br />
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Destacados" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="BusquedaAvanzada" Runat="Server">
</asp:Content>